Private Sub mnuPrintSimplePrint_Click() Dim result%
' When printing with PrintReport, no parameters are needed except the
filename and print flag being set to true
result% = PEPrintReport(lblReportName.Caption, True, 0, "", 0, 0, 0, 0,
0, 0)
If result% <> 0 Then
MsgBox "Could not preview the report, check that the file name and
path are valid and that the file is a Crystal Reports file.",
vbOKOnly + vbCritical, "Serious Error"
End If
MsgBox "Simple Print Complete!", vbOKOnly, "Operation Succeeded"
End Sub
Private Sub mnuPrintSimplePreview_Click()
Dim result%, hwdPreview&
' In the Simple Print demonstration, there is no need to open and close
the report engine ' In the Simple Preview, if you don't open and close the report engine
manually, the preview window pops up and immediately disappears again. ' In addition, if you open the engine, run the preview and immediately
close the engine the preview window will disappear. ' To delay the closing of the engine (and premature removal of the
preview window) the Windows API calls GetActiveWindow and IsWindow keep
track of the existence of the preview window. As long as the preview
window exists, the report engine will not be closed. When the preview
window doesn't exist (ie - it has been closed), then the report engine
is closed.
' Opening the report engine - if something goes wrong, the program cannot
continue
result% = PEOpenEngine()
If result% = 0 Then
MsgBox "Could not start the report engine. Execution must halt.",
vbOKOnly + vbCritical, "Serious Error"
End
End If
' The global constants for the preview window parameters are in
SAMPLE.BAS
' Please refer to the custom-l ink preview function for additional
information about preview windows
result% = PEPrintReport(lblReportName.Caption, False, True, "Preview
Window" & Chr$(0), CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, WS_VISIBLE + WS_CAPTION + WS_BORDER + WS_SYSMENU +
WS_THICKFRAME + WS_MINIMIZEBOX + WS_MAXIMIZEBOX, 0)
' Check to see if the preview succeeded - if it did, grab its handle
If result% = 0 Then
' Get the handle to the active window, which will be the preview
window
hwdPreview& = GetActiveWindow()
' Loop as long as the preview window continues to exist
' DoEvents allows other programs to function (including the
preview window)
Do While IsWindow(hwdPreview&)
DoEvents
Loop
Else
MsgBox "Could not preview the report, check that the file name
and path are valid and that the file is a Crystal Reports file.",
vbOKOnly + vbCritical, "Serious Error"
End If
' Close the report engine
PECloseEngine
MsgBox "Simple Print Preview Complete!", vbOKOnly, "Operation Succeeded"
End Sub
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |